package zz;
class CPU {
    private int speed;

    public CPU(int speed) {
        this.speed = speed;
    }

    public int getSpeed() {
        return speed;
    }
}
 class HardDisk {
    private int amount;

    public HardDisk(int amount) {
        this.amount = amount;
    }

    public int getAmount() {
        return amount;
    }
}
 class PC {
    private CPU cpu;
    private HardDisk hardDisk; // 通常我们会将变量名命名为更有意义的名称，比如hardDisk而不是HD

    public void setCPU(CPU cpu) {
        this.cpu = cpu;
    }

    public void setHardDisk(HardDisk hardDisk) {
        this.hardDisk = hardDisk;
    }

    public void show() {
        System.out.println("CPU Speed: " + cpu.getSpeed() + " MHz");
        System.out.println("Hard Disk Capacity: " + hardDisk.getAmount() + " GB");
    }
}
public class Test {
    public static void main (String[] args) {
        // 创建CPU对象并设置速度（通过构造器）
        CPU cpu = new CPU(2200);

        // 创建HardDisk对象并设置容量（通过构造器）
        HardDisk hardDisk = new HardDisk(200);

        // 创建PC对象
        PC pc = new PC();

        // 设置PC的CPU和HardDisk
        pc.setCPU(cpu);
        pc.setHardDisk(hardDisk);

        // 显示CPU速度和硬盘容量
        pc.show();
    }
}


